<?php

namespace zhuli\web;

class Response
{
	private $data;
	private $responseFormat;
	/**
	 * send 发送响应内容
	 * @return void
	 */
	public function send()
	{
		if ($this->getFormat() == 'html') {
			header('Content-Type:text/html;charset=utf-8');
			echo $this->getData();
		}
		if ($this->getFormat() == 'json') {
			header('Content-Type:application/json;charset=utf-8');
			echo $this->getData();
		}
		if ($this->getFormat() == 'raw') {
			header('Content-Type:text/plain;charset=utf-8');
			echo $this->getData();
		}

	}

	/**
	 * setData 填充数据
	 * @param string $data 
	 */
	public function setData($data)
	{
		$this->data = $data;
	}

	/**
	 * getData 获取数据
	 * @return string
	 */
	public function getData()
	{
		return $this->data;
	}

	/**
	 * setFormat 设置响应数据类型
	 * @param string $format 数据类型
	 */
	public function setFormat($format)
	{
		$this->responseFormat = $format;
	}

	/**
	 * getFormat 获取响应数据类型
	 * @return sting 
	 */
	public function getFormat()
	{
		return $this->responseFormat;
	}

}